﻿#region Namespace Inclusions
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
#endregion

namespace SerialPort_URAT
{
    public partial class About : Form
    {
        private string TempFile = Path.GetTempFileName();
        public About()
        {
            InitializeComponent();

            // Read the about HTML from the assembly
            string html = (new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("SerialPort_URAT.About.htm"))).ReadToEnd();

            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                //this.Text = this.Text + "( Release Version : " + System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() + " )";
                // Replace sections with appropriate data
                //html = html.Replace("{version}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                html = html.Replace("{version}", System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString());
            }

            webBrowser1.DocumentText = html;

            //Assembly asm = Assembly.GetExecutingAssembly();
            //string PJname = asm.GetName().Name;
            // Read the about HTML from the assembly
            //string html = (new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(PJname + ".About.htm"))).ReadToEnd();
            //string html = (new StreamReader(@".\About.htm")).ReadToEnd();

            // Replace sections with appropriate data
            // html = html.Replace("{version}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            // html = html.Replace("{version}", asm.GetName().Version.ToString());

            // Save the temp file so the web browser has a target to navigate to
            //File.WriteAllText(TempFile, html);

            // Show the temp about file 
            //webBrowser1.Navigate(TempFile);
            //webBrowser1.Navigate(@".\About.htm");
        }

        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            // Since the navigation is complete, delete the temp file
            //File.Delete(TempFile);

        }
    }
}
